// 加载
let data = {
  pagenum: 1,
  pagesize: 8,
}
let arr = [`<div class="kr_news_date">
        17 <span>08月</span>
      </div>`];

let total = 10;



get()
function get() {
  $.ajax({
    url: 'http://localhost:8888/api/articles',
    data,
    success: function (res) {
      total = res.total;

      if (res.status === 0) {

        res.data.forEach(item => {
          arr.push(`<div class="item">
        <h4>
          <a href="./detail.html?id=${item.id}">${item.title}</a>
        </h4>
        <p class="meta">
          <span>15分钟前 分享至</span>
          <a href="javascript:;" class="wechat"></a>
          <a href="javascript:;" class="weibo"></a>
        </p>
        <p class="brief">${item.content}</p>
      </div>`)
        });
        let str = arr.join('');
        $('.kr_news_list').html(str);


      }
    }
  });
}


// 点击加载数据

$('.kr_more a').on('click', function (e) {

  console.log(total, arr.length);
  if (arr.length > total || total == undefined) layui.layer.msg('没有更多数据了');
  e.preventDefault();
  data.pagenum++;
  get();
});



